package com.example.picture;



import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Date;
import java.util.Scanner;

public class Model {
	private int sec;
	private int timing;
	private String output;
	private String seqno;
	Model(){
		sec=60;
		timing=100;
	}
	public void setSeqno(String str){
		seqno=str;
	}
	public String getOutput(){
		return output;
	}
	public int getTiming(){
		return timing;
	}
	
	public void Click(long now){
		
		output=Hash(String.valueOf(now/1000/60)+seqno);
		
		output=calcToken(output);
		timing=(int)(sec-(now/1000%60));
	}

	private String calcToken(String str){
		int sum=0;
		for(int i=0;i<str.length();i++){
			sum^=(str.charAt(i)<<((i&0x3)<<3));
			sum^=(str.charAt(i)<<((i^0x3)<<3));
			sum%=1000000;
		}
		String s=String.valueOf(sum);
		while(s.length()<6)
			s="0"+s;
		return s;
	}
	private  String Hash(String str)
	{
		if (str == null || str.length() == 0) {
			throw new IllegalArgumentException("String to encript cannot be null or zero length");
		}
		StringBuffer hexString = new StringBuffer();
		try {
			MessageDigest md = MessageDigest.getInstance("MD5");
			md.update(str.getBytes());
			byte[] hash = md.digest();
			for (int i = 0; i < hash.length; i++) {
				if ((0xff & hash[i]) < 0x10) {
					hexString.append("0" + Integer.toHexString((0xFF & hash[i])));
				}    
				else {
					hexString.append(Integer.toHexString(0xFF & hash[i]));
				}    
			}
		}
		catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		}

		return hexString.toString();
	}
	public static void main(String agrs[]) {
		Model md5=new Model();
		
		Scanner s=new Scanner(System.in);
		md5.setSeqno("123");  //
		while(s.next() != null){
			long time=System.currentTimeMillis();
			md5.Click(time);
			System.out.println(String.valueOf(time/1000/60)+"  "+md5.getOutput() + "  "+"   "+ md5.getTiming()+"  "+new Date());
		}
	}
//a2f3e71d9181a67b// 0cc175b9c0f1b6a831c399e269772661
 //900150983cd24fb0d6963f7d28e17f72
}